package com.kania.simpleemail.data;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class EmailDBHelper extends SQLiteOpenHelper{

	public static final String EMAIL_DB_NAME = "simpleemail.db";
	public static final String EMAIL_TABLE_NAME = "messages";
	
	public EmailDBHelper(Context context) {
		super(context, EMAIL_DB_NAME, null, 2);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS " 
				+ EMAIL_TABLE_NAME 
				+ " (_id INTEGER PRIMARY KEY AUTOINCREMENT, account TEXT, uid INTEGER, sender TEXT, receiver TEXT, cc TEXT, bcc TEXT, subject TEXT, date TEXT, contents TEXT);");
		//일단 contents 는 텍스트로 받아오도록 함.
		//from은 쿼리문에 keyword로 사용하므로 sender로 사
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXIST " + EMAIL_TABLE_NAME);
		onCreate(db);
	}
}
